/*
 * LightSensor.java
 *
 * Created on June 16, 2007, 7:47 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package atag.runtime.sensors;

import com.sun.spot.sensorboard.IDemoBoard;
import com.sun.spot.sensorboard.EDemoBoard; 
import com.sun.spot.sensorboard.peripheral.ILightSensor;  
import com.sun.spot.util.Utils;
import java.io.IOException;

/**
 *
 * @author Sirius
 */
public class HumiditySensor implements ATaGSensor {
    
    private int maxReading;
    private int currentReading;

    private IDemoBoard sensorBoard;
    private ILightSensor humiditySensor;
    /** Creates a new instance of LightSensor */
    public HumiditySensor() {
           
        sensorBoard = EDemoBoard.getInstance();
        humiditySensor = sensorBoard.getLightSensor();   
//        try {
//            this.maxReading = lightSensor.getRange();
//        }
//        catch (IOException ex) {
//            ex.printStackTrace();
//        }
//        
//        currentReading = 0;        
    }
    
    public int getMaxReading() {
        try {
            this.maxReading = humiditySensor.getRange();
        }
        catch (IOException ex) {
            ex.printStackTrace();
        }
        return this.maxReading;
    }
    
    public int getCurrentReading() {
        int currentHumidityValue = -1;
        try {
            currentHumidityValue = this.humiditySensor.getValue();      // Ranges from 0 - 740
        }
        catch (IOException ex) {
            ex.printStackTrace();
        }
        return currentHumidityValue;
    }
    
}
